﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="CommentGrid.ascx.cs"
    Inherits="SLIITPro.SysUsers.CommentGrid" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<div class="grid">
    <div class="rounded">
        <div class="top-outer">
            <div class="top-inner">
                <div class="top">
                    <h2>
                        Comment Edit</h2>
                </div>
            </div>
        </div>
        <div class="mid-outer">
            <div class="mid-inner">
                <div class="mid">
                    <asp:UpdatePanel ID="upCommentEdit" runat="server" UpdateMode="Conditional">
                        <ContentTemplate>
                            <!-- Content Goes Here! -->
                            <asp:GridView ID="grdComment" runat="server" AllowPaging="True" CssClass="datatable"
                                AutoGenerateColumns="False" DataKeyNames="Id" OnPageIndexChanging="grdComment_IndexChanging"
                                PageSize="10" OnSelectedIndexChanged="grdComment_SelectedIndexChanged" GridLines="None">
                                <Columns>
                                    <asp:TemplateField ShowHeader="False">
                                        <ItemTemplate>
                                            <asp:CheckBox ID="chkDelete" runat="server" />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="ID">
                                        <ItemTemplate>
                                            <asp:Label ID="lblId" runat="server" Text='<%# Bind("Id") %>'></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:BoundField DataField="Author" HeaderText="Author" SortExpression="Author" />
                                    <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
                                    <asp:BoundField DataField="DateCreated" HeaderText="Date Created" ReadOnly="true"
                                        SortExpression="DateCreated" />
                                    <asp:TemplateField HeaderText="Content" SortExpression="Content">
                                        <ItemTemplate>
                                            <asp:LinkButton ID="lnkBtnContent" runat="server" Text='<%# Bind("Content") %>'
                                                CommandName="Select"></asp:LinkButton>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Comment Approve" SortExpression="cmIsApproved">
                                        <ItemTemplate>
                                            <asp:LinkButton ID="HyperLinkApprove" runat="server" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "Id") %>'
                                                ForeColor='<%#GetLinkColor((bool)DataBinder.Eval(Container.DataItem, "IsApproved")) %>'
                                                OnClick="HyperLinkApprove_Click" Text='<%#GetLinkText((bool)DataBinder.Eval(Container.DataItem, "IsApproved")) %>'>
                                            </asp:LinkButton>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                </Columns>
                                <PagerSettings Mode="NextPreviousFirstLast" Position="Bottom" PageButtonCount="20" />
                                <PagerStyle CssClass="pager-row" />
                                <RowStyle CssClass="row" />
                            </asp:GridView>
                            <div class="buttondiv">
                                <asp:Button ID="btnSelectAll" runat="server" Text="Select All" CssClass="cssbutton"
                                    Width="75px" OnClick="btnSelectAll_Click" />
                                <asp:Button ID="btnMultiDelete" runat="server" Text="Delete" CssClass="cssbutton"
                                    Width="75px" OnClientClick="return confirm('Are you sure want to delete this record?');"
                                    OnClick="btnMultiDelete_Click" />
                            </div>
                        </ContentTemplate>
                    </asp:UpdatePanel>
                </div>
            </div>
        </div>
        <div class="bottom-outer">
            <div class="bottom-inner">
                <div class="bottom">
                </div>
            </div>
        </div>
    </div>
</div>
<asp:Panel ID="pnlPopup" runat="server" CssClass="detail" Width="500px" Style="display: none">
    <asp:UpdatePanel ID="updPnlComment" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
            <asp:Button ID="btnShowPopup" runat="server" Style="display: none" />
            <cc1:ModalPopupExtender ID="mdlPopup" runat="server" TargetControlID="btnShowPopup"
                PopupControlID="pnlPopup" CancelControlID="btnClose" BackgroundCssClass="modalBackground"
                Enabled="true" />
            <asp:DetailsView ID="dvComment" runat="server" DataSourceID="dsCommentUpdate" CssClass="detailgrid"
                GridLines="None" DefaultMode="Edit" AutoGenerateRows="False" Visible="False"
                Width="100%" DataKeyNames="cmId">
                <Fields>
                    <asp:BoundField DataField="cmId" HeaderText="Comment ID" InsertVisible="False" ReadOnly="True"
                        SortExpression="cmId" />
                    <asp:TemplateField HeaderText="Email">
                        <EditItemTemplate>
                            <asp:TextBox ID="txtEmail" runat="server" Text='<%# Bind("cmEmail") %>' CssClass="droplist"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="rfBEmail" runat="server" ControlToValidate="txtEmail"
                                Display="Dynamic" ErrorMessage="Required" ValidationGroup="details"></asp:RequiredFieldValidator>
                            <asp:RegularExpressionValidator ID="regBEmail" runat="server" ControlToValidate="txtEmail"
                                Display="Dynamic" ErrorMessage="&lt;br /&gt;Please enter a Email address in the format:&lt;br /&gt;name@yourdomian.com"
                                ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ValidationGroup="details"></asp:RegularExpressionValidator>
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Content">
                        <EditItemTemplate>
                            <asp:TextBox ID="txtContent" runat="server" Text='<%# Bind("cmContent") %>' TextMode="MultiLine"
                                Width="350px" Rows="10" CssClass="droplist"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="rfBAddress" runat="server" ControlToValidate="txtContent"
                                Display="Dynamic" ErrorMessage="Required" ValidationGroup="details"></asp:RequiredFieldValidator>
                        </EditItemTemplate>
                    </asp:TemplateField>
                </Fields>
            </asp:DetailsView>
            <div class="footer">
                <asp:Button ID="btnDelete" runat="server" Text="Delete" CssClass="cssbutton" Width="75px"
                    OnClientClick="return confirm('Are you sure wants to delete this record?');"
                    ValidationGroup="details" CausesValidation="true" />
                <asp:Button ID="btnSave" runat="server" Text="Save" CssClass="cssbutton" Width="75px"
                    ValidationGroup="details" CausesValidation="true" />
                <asp:Button ID="btnClose" runat="server" Text="Close" CssClass="cssbutton" Width="75px"
                    CausesValidation="false" />
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Panel>
<asp:SqlDataSource ID="dsCommentUpdate" OnSelecting="dsCommentUpdate_Selecting" runat="server"
    ConnectionString="<%$ ConnectionStrings:SLIITProConnectionString %>" DeleteCommand="DELETE FROM [Comments] WHERE [cmId] = @cmId"
    SelectCommand="SELECT [cmId],[cmEmail], [cmContent] FROM [Comments] WHERE ([cmId] = @cmId)"
    UpdateCommand="UPDATE [Comments] SET [cmEmail] = @cmEmail, [cmContent] = @cmContent WHERE [cmId] = @cmId">
    <SelectParameters>
        <asp:Parameter Name="cmId" Type="String" />
    </SelectParameters>
    <DeleteParameters>
        <asp:Parameter Name="cmId" Type="String" />
    </DeleteParameters>
    <UpdateParameters>
        <asp:Parameter Name="cmEmail" Type="String" />
        <asp:Parameter Name="cmContent" Type="String" />
        <asp:Parameter Name="cmId" Type="String" />
    </UpdateParameters>
</asp:SqlDataSource>
